package org.yenn.pattern.aliyun.behavioral.nullobject;

import org.junit.Test;

import static org.junit.Assert.*;

/**
 * 步骤 4
 * 使用 CustomerFactory，基于客户传递的名字，来获取 RealCustomer 或 NullCustomer 对象。
 */
public class NullPatternDemo {
    /**
     * 步骤 5
     * 验证输出。
     *
     * Customers
     * Rob
     * Not Available in Customer Database
     * Julie
     * Not Available in Customer Database
     */
    @Test
    public void getName() {

        // names = {"Rob", "Joe", "Julie"};
        AbstractCustomer customer1 = CustomerFactory.getCustomer("Rob");
        AbstractCustomer customer2 = CustomerFactory.getCustomer("Bob");
        AbstractCustomer customer3 = CustomerFactory.getCustomer("Julie");
        AbstractCustomer customer4 = CustomerFactory.getCustomer("Laura");

        System.out.println("Customers");
        System.out.println(customer1.getName());
        System.out.println(customer2.getName());
        System.out.println(customer3.getName());
        System.out.println(customer4.getName());
    }
}